home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Science⁄Math / VideoToolbox / VideoToolboxSources / TrapAvailable.c < prev    next >
Text File  |  1993-05-11  |  834b  |  40 lines

  1. /*
  2. TrapAvailable.c
  3. From Apple. Simply include <Traps.h> in your program and call this routine to find
  4. out whether any particular trap is available.
  5. */
  6. #include "VideoToolbox.h"
  7. #include <Traps.h>
  8.  
  9. // these are for internal use only
  10. short NumToolboxTraps(void);        
  11. TrapType GetTrapType(short theTrap);
  12.     
  13. Boolean    TrapAvailable(short theTrap)
  14. {
  15.     TrapType tType;
  16.     
  17.     tType=GetTrapType(theTrap);
  18.     if(tType==ToolTrap){
  19.         theTrap &= 0x07FF;
  20.         if(theTrap>=NumToolboxTraps())theTrap=_Unimplemented;
  21.     }
  22.     return NGetTrapAddress(theTrap,tType) != NGetTrapAddress(_Unimplemented,ToolTrap);
  23. }
  24.  
  25. short NumToolboxTraps(void)
  26. {
  27.     if (NGetTrapAddress(_InitGraf,ToolTrap) == NGetTrapAddress(0xAA6E,ToolTrap))
  28.         return 0x0200;
  29.     else return 0x0400;
  30. }
  31.  
  32.  
  33. TrapType GetTrapType(short theTrap)
  34. {
  35.     if((theTrap & 0x0800)>0) return ToolTrap;
  36.     else return OSTrap;
  37. }
  38.  
  39.  
  40.